<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
	 <meta charset="UTF-8">
	 <title th:replace="common/base::pagetitle"></title>
	 <link th:replace="common/base::static"/>
</head>
<body>
<div class="layui-form" style="padding: 20px 30px 0 0;">
	 <div class="layui-form-item">
		  <label class="layui-form-label">名称</label>
		  <div class="layui-input-inline">
				<input type="text" name="name" th:value="${editInfo.name}" lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
		  </div>
	 </div>
	<div class="layui-form-item">
		<label class="layui-form-label">工商注册号</label>
		<div class="layui-input-inline">
			<input type="text" name="comCerNo" th:value="${editInfo.comCerNo}" lay-verify="required" placeholder="请输入工商注册号" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">公司地址</label>
		<div class="layui-input-inline">
			<input type="text" name="comAddress" th:value="${editInfo.comAddress}" lay-verify="required" placeholder="请输入工商地址" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
	<label class="layui-form-label">管理人证件号码</label>
	<div class="layui-input-inline">
		<input type="text" name="admCerNo" th:value="${editInfo.admCerNo}" lay-verify="required" placeholder="请输入管理人证件号码" autocomplete="off" class="layui-input">
	</div>
</div>
	<div class="layui-form-item">
		<label class="layui-form-label">管理人手机号</label>
		<div class="layui-input-inline">
			<input type="text" name="admMobPhone" th:value="${editInfo.admMobPhone}" lay-verify="required" placeholder="请输入管理人手机号" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">管理人姓名</label>
		<div class="layui-input-inline">
			<input type="text" name="admName" th:value="${editInfo.admName}" lay-verify="required" placeholder="请输入管理人姓名" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">营业执照url</label>
		<div class="layui-input-inline">
			<input type="text" name="busLicImageUrl" th:value="${editInfo.busLicImageUrl}" lay-verify="required" placeholder="请输入营业执照url" autocomplete="off" class="layui-input">
		</div>
	</div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">排序号</label>
		  <div class="layui-input-inline">
				<input type="text" name="sort" th:value="${editInfo.sort==null?'0':editInfo.sort}" lay-verify="required" placeholder="请输入排序号" autocomplete="off" class="layui-input">
		  </div>
	 </div>
<!--	<div class="layui-form-item">-->
<!--		<label class="layui-form-label">appId</label>-->
<!--		<div class="layui-input-inline">-->
<!--			<input type="text" name="appId" th:value="${editInfo.appId}" lay-verify="required" placeholder="请输入appId" autocomplete="off" class="layui-input">-->
<!--			<input type="hidden" name="orgId" th:value="${editInfo.orgId}" autocomplete="off" class="layui-input">-->
<!--		</div>-->
<!--	</div>-->
	<div class="layui-form-item" th:style="${editInfo.comId!=null} ? 'display: none' : ''">
		<label class="layui-form-label">机构标识</label>
		<div class="layui-input-inline">
			<input type="text"  name="comId" th:value="${editInfo.comId}" lay-verify="required" placeholder="请输入机构标识" autocomplete="off" class="layui-input">
		</div>
	</div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">状态</label>
		  <div class="layui-input-inline">
				<input type="checkbox" lay-filter="status" name="status" value="0" th:checked="${editInfo.status==null||editInfo.status==0}" lay-skin="switch" lay-text="正常|禁用">
		  </div>
	 </div>
	 <div class="layui-form-item">
		  <label class="layui-form-label">类型</label>
		  <div class="layui-input-block" id="typeRadio">
				<input type="radio" name="type" value="0" title="供应商" autocomplete="off" class="layui-input" th:checked="${editInfo.type==null || editInfo.type==0}">
				<input type="radio" name="type" value="1" title="核心企业" autocomplete="off" class="layui-input"  th:checked="${editInfo.type==1}">
				<input type="radio" name="type" value="2" title="银行" autocomplete="off" class="layui-input" th:checked="${editInfo.type==2}">
				<input type="radio" name="type" value="9" title="平台" autocomplete="off" class="layui-input" th:checked="${editInfo.type==9}">
		  </div>
	 </div>
	<div class="layui-form-item">
	<label class="layui-form-label">机构来源</label>
	<div class="layui-input-block" id="sourceRadio">
		<input type="radio" name="source" value="0" title="集采推送" autocomplete="off" class="layui-input"  th:checked="${editInfo.source==null || editInfo.source=='0'}">
		<input type="radio" name="source" value="1" title="其他" autocomplete="off" class="layui-input"  th:checked="${editInfo.source=='1'}">
	</div>
</div>
<!--	<div class="layui-form-item">-->
<!--		<label class="layui-form-label">营业执照</label>-->
<!--		<div class="layui-input-inline">-->
<!--			<input type="text" name="busLicImageUrl" th:value="${editInfo.busLicImageUrl}" lay-verify="required" placeholder="请输入营业执照" autocomplete="off" class="layui-input">-->
<!--		</div>-->
<!--	</div>-->
	<div class="layui-form-item layui-hide">
		  <input type="button" lay-submit="" lay-filter="kFormSubmit" id="kFormSubmit" value="确认添加">
		  <input type="text" name="id" th:value="${editInfo.id}" placeholder="保存ID" autocomplete="off" class="layui-input">
		  <input type="text" name="parentId" th:value="${editInfo.parentId}" placeholder="保存parentId" autocomplete="off" class="layui-input">
	 </div>
</div>

<script th:replace="common/base::context"></script>
<script th:replace="common/base::mainjs"></script>
<script>
    layui.use(['form'], function () {
        var $ = layui.$, form = layui.form;

        var parentId = wlbKit.getUrlParam('parentId');
        // var type = wlbKit.getUrlParam('type');

        // var $typeRadioEl = $('#typeRadio');
        // if (type) {
        //     switch (Number(type)) {
        //         case 0:
        //             $typeRadioEl.append('<input type="radio" name="type" value="0" title="公司" autocomplete="off" class="layui-input" checked>');
        //             break;
        //         case 1:
        //             $typeRadioEl.append('<input type="radio" name="type" value="1" title="部门" autocomplete="off" class="layui-input" checked>');
        //             break;
        //         case 2:
        //             $typeRadioEl.append('<input type="radio" name="type" value="2" title="科室" autocomplete="off" class="layui-input" checked>');
        //     }
        // }
        // form.render('radio');

        //监听提交
        form.on('submit(kFormSubmit)', function (data) {
            var field = data.field; //获取提交的字段
            field.parentId = 0;  // 父级ID
            // field.type = type;  // 类型
            field.status = field.status || 1;
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

            log('field=', field);

            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.ajax({
                type: req.type.post,
                url: field.id ? api.sys.deptEdit : api.sys.deptAdd,
                data: field,
                async: false,
                success: function (r) {
                    if (r.code === req.status.ok) {
                        // 重载kContentTable表格
						parent.layui.table.reload('kContentTable'); //重载表格
                        parent.layer.close(index); //再执行关闭
                    } else {
                        wlbKit.errorMsg(r.msg);
                    }
                }
            });

        });

    })
</script>
</body>
</html>
